home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / oper_sys / emerald / emrldsys.lha / Language / ExecTests / tvector.m < prev   
Text File  |  1990-08-31  |  1KB  |  53 lines

  1. import runtest from "RunTest"
  2.  
  3. const tvector <- object tvector
  4.   const myTest == runtest.create[stdin, stdout, "tvector"]
  5.   process
  6.     const v == { 4 }
  7.     const w == { }
  8.     const x == { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 : Any }
  9.     const y == { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }
  10.     const z == Vector.of[Integer].create[10]
  11.  
  12.     var i : Integer
  13.     myTest.check[v.lowerbound = 0, "v.lowerbound = 0"]
  14.     myTest.check[v.upperbound = 0, "v.upperbound = 0"]
  15.  
  16.     myTest.check[w.lowerbound = 0, "w.lowerbound = 0"]
  17.     myTest.check[w.upperbound = ~1, "w.upperbound = ~1"]
  18.     
  19.     myTest.check[x.lowerbound = 0, "x.lowerbound = 0"]
  20.     myTest.check[x.upperbound = 9, "x.upperbound = 9"]
  21.  
  22.     i <- 0
  23.     loop
  24.       exit when i > x.upperbound
  25.       myTest.check[(view x(i) as Integer) = i,
  26.     "(view x(i) as Integer) = i (i = " || i.asString || ")"]
  27.       i <- i + 1
  28.     end loop
  29.  
  30.     myTest.check[y.lowerbound = 0, "y.lowerbound = 0"]
  31.     myTest.check[y.upperbound = 9, "y.upperbound = 9"]
  32.  
  33.     i <- 0
  34.     loop
  35.       exit when i > y.upperbound
  36.       myTest.check[i = y(i), "y(i) = i (i = " || i.asString || ")"]
  37.       i <- i + 1
  38.     end loop
  39.  
  40.     i <- 0
  41.     loop
  42.       exit when i > y.upperbound
  43.       z(i) := y(i) * y(i) + y(i) + y(i)
  44.       myTest.check[z(i) = i*i+i+i, "z(i) = i*i+i+i"]
  45.       z(i) := i * i + i + i
  46.       myTest.check[z(i) = i*i+i+i, "z(i) = i*i+i+i"]
  47.       i <- i + 1
  48.     end loop
  49.     
  50.     myTest.done
  51.   end process
  52. end tvector
  53.